Skip to content

Fix lab CLI lines and Python/Terraform snippets found by replaying every lab - #82

Merged
returnvalue merged 4 commits into
mainfrom
claude/project-thread-pep0g5
Nov 8, 2026
Merged

returnvalue merged 4 commits into
mainfrom
claude/project-thread-pep0g5

Conversation

@returnvalue

Copy link
Copy Markdown
Collaborator

Requested by Chris

What

I checked every lab's CLI, Python and Terraform snippets (120 labs, 810 steps) and fixed the bugs that would break for a learner who copies them.

How they were checked

  • Every complete aws line went through the AWS CLI's own argument parser, and every lab command through bash quoting rules.
  • Every step's file (artifact) was parsed as the CLI parameter it fills.
  • Every boto3 snippet was run with botocore's parameter validation, and replayed live on a throwaway Floci 2.4.0.
  • Every Terraform snippet passed terraform validate with AWS provider 6.72, then apply and destroy per step on a second throwaway Floci.

Lab command fixes

  • Organizations create-policy was missing the required --description (SCPs and the tag policy).
  • Unquoted shorthand with {a,b} was brace-expanded by the shell into two arguments. Affected: Lambda --environment, Firehose buffering hints, CodeBuild environment and report export, the RI budget, put-metric-data dimensions, ECS --network-configuration and SageMaker input channels.
  • --stage-name $default was emptied by the shell. It now reads '$default'.
  • The guided EC2 send-command used commands='… "…"', which the CLI rejects.
  • The SQS batch files held {"Entries": [...]} and the EventBridge targets file held one object. --entries and --targets take the list itself.
  • The SQS create-queue --attributes file was a bare policy. It is now an attributes map with Policy.

Snippet generator fixes (snippets.py)

  • Python wraps calls the lab marks as failing ("refused", "denied", …Exception) in try/except ClientError, so the rest of the script still runs.
  • CLI doubles now render as plain numbers. Before, they rendered as Decimal(...) with no import.
  • Shortened (...) or placeholder shorthand keeps <placeholders> (numbers become named constants) and drops fragments that only half-parse, such as Entries=[{'ref': ...}].
  • Terraform aws_flow_log uses log_destination, because provider 6 removed log_group_name.

New tests

  • Every complete CLI line parses with the AWS CLI.
  • Every lab command survives the shell.
  • Every artifact fits its CLI parameter.
  • Every boto3 snippet's literal values fit the API shapes and use only defined names.

Tests

  • python manage.py test --noinput: 2,155 pass
  • ruff check .: clean

🤖 Generated with Claude Code

Chris and others added 4 commits November 7, 2026 17:34
…ery lab

Lab commands:
- Organizations create-policy lines pass the required --description.
- Shorthand values with {a,b} are quoted, so the shell doesn't brace-expand them
  (Lambda environment, Firehose buffering hints, CodeBuild environment and report
  export, RI budget, put-metric-data dimensions, ECS network configuration,
  SageMaker input channels).
- apigatewayv2 create-stage quotes '$default', which the shell would empty.
- The guided EC2 send-command uses a JSON list the CLI accepts.
- SQS batch entry files and the EventBridge targets file hold the list the CLI
  option expects; the SQS create-queue attributes file is an attributes map.

Snippets:
- Python catches the errors a lab marks as expected (refused, denied, ...) so
  the rest of the script still runs.
- CLI doubles render as plain numbers instead of an unimported Decimal.
- Abbreviated or placeholder shorthand keeps placeholders and drops fragments
  that only half-parse.
- Terraform flow logs use log_destination (AWS provider 6 removed log_group_name).

Tests: every complete CLI line parses with the AWS CLI, every lab command
survives the shell, every artifact fits its CLI parameter, and every boto3
snippet's literal values fit the API shapes and use only defined names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A role policy, group membership, event rule or subscription named its parent
with a literal string, so terraform apply could create it before the parent
and fail with NoSuchEntity / not found. Names and ARNs of resources declared
earlier in a snippet now become references (aws_iam_role.x.name, .arn), which
orders creation. All 359 Terraform snippets pass terraform validate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`--instance-ids i-1 ... commands=[...]` put the commands into InstanceIds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eates

A step that creates a KMS key and then aliases <key-id>, or a security group
and then adds rules to <web-sg-id>, asked for the ID as a variable, so one
apply could never work. Those placeholders now reference the resource
(aws_kms_key.x.key_id, aws_security_group.x.id, ...) and the unused variable
goes away. KMS TagKey/TagValue tags render as a map instead of { None = null }.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@returnvalue
returnvalue merged commit 504b44d into main Nov 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant